{% extends "school/layout.html" %}

{% set page_title = translate('学生成绩查询') %}

{% block content %}
<style>
th {
    text-align: center;
    background-color: #e2e2e2;
    padding: 8px 0;
}
table{
    padding:3px;
    text-align:center;
    border:1px #cccccc solid;
    margin-top:150px;
    width: 100%;
    font-family: "Helvetica Neue", Helvetica, sans-serif, "STHeiti", "Microsoft Yahei", Arial;
}
td {
    padding: 8px 0;
}
.nopass{
    color: #e36f7e;
}
.good{
    color: #f5a623;
}
.very-good{
    color: #dcb81c;
}
.great{
    color: #67B021;
}
.activitynotgoing {
    color: #9e9e9e;
}
.sessionnotgoing {
    color: #9e9e9e;
}
.unfinished {
    color: #9e9e9e;
}
</style>
<div class="m-scontent">
<div class="m-fixed-table-top">
    <div class="title">
        <div class="name">{{translate('学生姓名')}}：{{ student.name }}
            <a class="modified" href="{{ url_for('school.edit_student', sid=student.id) }}">{{translate('学生信息')}}</a>
        </div>
        <p class="text">
            <span>{{translate('任课教师')}}：{{ music_class.teacher.name }}</span>
            <span>{{translate('所在班级')}}：{{ music_class.name }}</span>
            {% if sessions %}
                {% if course_map and course_map.startswith('evaluation') %}
                    <span>{{translate('进度：我的旅途')}}－{{ translate(sessions[0].evaluation) }}</span>
                {% else %}
                    <span>{% if course_map %}{{translate('进度：我的旅途')}}－{% endif %}{{ sessions[0].description if 'description' in sessions[0] else sessions[0].number }}.{{ translate(sessions[0].lesson) }}</span>
                {% endif %}
            {% endif %}
            {% if course_map %}
            <select name='sel' id="sel" style="font-size: initial;" onchange="loc()">
              <option value ="/map1" {% if course_map=='map1' %}selected{% endif %}>{{translate('爱丽丝小镇')}}</option>
              <option value ="/map2" {% if course_map=='map2' %}selected{% endif %}>{{translate('威尔第雪山')}}</option>
              <option value ="/map3" {% if course_map=='map3' %}selected{% endif %}>{{translate('索拉朵之海')}}</option>
              <option value ="/evaluation" {% if course_map=='evaluation' %}selected{% endif %}>{{translate('测评成绩')}}</option>
            </select>
            {% endif %}
        </p>
    </div>
</div>


{% if course_map=='map1' %}
<table name='map1'  cellpadding="1" border='1'>
    <tr>
        <th>{{translate('上课时间')}}</th>
        <th>{{translate('总分')}}</th>
        <th>{{translate('学习课程')}}</th>
        <th>{{translate('卡拉PK')}}</th>
        {% if system_version == "1" %}
        <th>{{translate('曲谱PK')}}</th>
        <th>{{translate('无灯PK')}}</th>
        {% else %}
        <th>{{translate('曲谱PK(慢速)')}}</th>
        <th>{{translate('曲谱PK(中速)')}}</th>
        <th>{{translate('曲谱PK(原速)')}}</th>
        {% endif %}
        <th>{{translate('演奏')}}</th>
        <th>{{translate('乐理')}}</th>
        <th>{{translate('听力')}}</th>
    </tr>

    {% for d in sessions %}
    <tr>
         <td rowspan={{ d.lessons | length }}>{{ d.time }}</td>
         <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ translate(d.remark) }}</span></td>

         {% for l, score in d.lessons.iteritems() %}
         {% if score.number == "01" or score.number == "02" %}
         <td class="name" id="lesson_s.id">{{ score.number }}.{{ translate(l) }}</td>
         {% if system_version == "1" %}
         <td colspan="6">{{translate('本课无PK/小考核')}}</td>
         {% else %}
         <td colspan="7">{{translate('本课无PK/小考核')}}</td>
         {% endif %}
         {% else %}
         {% if d.is_exp_class == True %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ translate(l) }}({{translate('体验课')}})</td>
        {% else %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ translate(l) }}</td>
        {% endif %}
         <td id="{{ score.pk_kara.activity_id if 'pk_kara' in score}}" ><span class="activity{% if 'pk_kara' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_kara.score }}{% endif %}</span></td>
         {% if system_version == "1" %}
         <td id="{{ score.pk_score.activity_id if 'pk_score' in score}}" ><span class="activity{% if 'pk_score' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_score.score }}{% if score.pk_score.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.pk_no_led.activity_id if 'pk_no_led' in score}}" ><span class="activity{% if 'pk_no_led' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_no_led.score }}{% if score.pk_no_led.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         {% else %}
         <td id="{{ score.pk_score_slow.activity_id if 'pk_score_slow' in score}}" ><span class="activity{% if 'pk_score_slow' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_score_slow.score }}{% if score.pk_score_slow.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.pk_score_mid.activity_id if 'pk_score_mid' in score}}" ><span class="activity{% if 'pk_score_mid' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_score_mid.score }}{% if score.pk_score_mid.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.pk_score.activity_id if 'pk_score' in score}}" ><span class="activity{% if 'pk_score' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_score.score }}{% if score.pk_score.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         {% endif %}
         <td id="{{ score.test_play.activity_id if 'test_play' in score}}" ><span class="activity{% if 'test_play' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_play.score }}{% if score.test_play.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.test_music_theory.activity_id if 'test_music_theory' in score}}" >
             <span class="activity{% if 'test_music_theory' not in score %}notgoing">
                 {{translate('未进行')}}{% else %}">
                 {% if not score.test_music_theory %}
                    {{translate('无此步骤')}}
                {% else %}
                    {{ score.test_music_theory.score }}
                {% endif %}
                {% endif %}</span></td>
         <td id="{{ score.test_listen.activity_id if 'test_listen' in score}}" >
             <span class="activity{% if 'test_listen' not in score %}notgoing">
                 {{translate('未进行')}}{% else %}">
                    {% if not score.test_listen %}
                        {{translate('无此步骤')}}
                    {% else %}
                        {{ score.test_listen.score }}
                    {% endif %}
                {% endif %}</span></td>
        {% endif %}
     </tr>
     {% if not loop.last%}<tr>{% endif %}
         {% endfor %}
    {% endfor %}
</table>
{% endif %}

{% if course_map=='map2' %}
<table name='map2' cellpadding="1" border='1'>
    <tr>
        <th>{{translate('上课时间')}}</th>
        <th>{{translate('总分')}}</th>
        <th>{{translate('学习课程')}}</th>
        <th>{{translate('分句PK')}}</th>
        <th>{{translate('全曲PK')}}</th>
        <th>{{translate('演奏')}}</th>
        <th>{{translate('乐理')}}</th>
        <th>{{translate('听力')}}</th>
    </tr>
    {% for d in sessions %}
    <tr>
         <td rowspan={{ d.lessons | length }}>{{ d.time }}</td>
         <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ translate(d.remark) }}</span></td>

        {% for l, score in d.lessons.iteritems() %}
        {% if d.is_exp_class == True %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ translate(l) }}({{translate('体验课')}})</td>
        {% else %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ translate(l) }}</td>
        {% endif %}
         <td id="{{ score.pk_part.activity_id if 'pk_part' in score}}" ><span class="activity{% if 'pk_part' not in score %}notgoing">{{translate('未进行')}}{% else %}">{% if not score.pk_part %}{{translate('无分句PK')}}{% else %}{{ score.pk_part.score }}{% if score.pk_part.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}{% endif %}</span></td>
         <td id="{{ score.pk_full.activity_id if 'pk_full' in score}}" ><span class="activity{% if 'pk_full' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_full.score }}{% if score.pk_full.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.test_play.activity_id if 'test_play' in score}}" ><span class="activity{% if 'test_play' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_play.score }}{% if score.test_play.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.test_music_theory.activity_id if 'test_music_theory' in score}}" ><span class="activity{% if 'test_music_theory' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_music_theory.score }}{% endif %}</span></td>
         <td id="{{ score.test_listen.activity_id if 'test_listen' in score}}" ><span class="activity{% if 'test_listen' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_listen.score }}{% endif %}</span></td>
     </tr>
     {% if not loop.last%}<tr>{% endif %}
         {% endfor %}
    {% endfor %}
</table>
{% endif %}

{% if course_map=='map3' %}
<table name='map3' cellpadding="1" border='1'>
    <tr>
        <th>{{translate('上课时间')}}</th>
        <th>{{translate('总分')}}</th>
        <th>{{translate('学习课程')}}</th>
        <th>{{translate('分句PK')}}</th>
        <th>{{translate('全曲PK')}}</th>
        <th>{{translate('演奏')}}</th>
        {% if not music_class.course_type=='course_adults' or music_class.course_type=='course_xi_yang_hong' %}
        <th>{{translate('乐理')}}</th>
        <th>{{translate('听力')}}</th>
        {% endif %}
    </tr>

    {% for d in sessions %}
    <tr>
         <td rowspan={{ d.lessons | length }}>{{ d.time }}</td>
         <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ translate(d.remark) }}</span></td>

         {% for l, score in d.lessons.iteritems() %}
         {% if d.is_exp_class == True %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ translate(l) }}({{translate('体验班')}})</td>
         {% else %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ translate(l) }}</td>
         {% endif %}
         <td id="{{ score.pk_part.activity_id if 'pk_part' in score}}" ><span class="activity{% if 'pk_part' not in score %}notgoing">{{translate('未进行')}}{% else %}">{% if not score.pk_part %}{{translate('无分句PK')}}{% else %}{{ score.pk_part.score }}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.pk_full.activity_id if 'pk_full' in score}}" ><span class="activity{% if 'pk_full' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.pk_full.score }}{% if score.pk_full.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.test_play.activity_id if 'test_play' in score}}" ><span class="activity{% if 'test_play' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_play.score }}{% if score.test_play.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
         <td id="{{ score.test_music_theory.activity_id if 'test_music_theory' in score}}" ><span class="activity{% if 'test_music_theory' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_music_theory.score }}{% endif %}</span></td>
         <td id="{{ score.test_listen.activity_id if 'test_listen' in score}}" ><span class="activity{% if 'test_listen' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_listen.score }}{% endif %}</span></td>
     </tr>
     {% if not loop.last%}<tr>{% endif %}
         {% endfor %}
    {% endfor %}
</table>
{% endif %}

{% if course_map and course_map.startswith('evaluation') %}
<table name='evaluation'  cellpadding="1" border='1'>
    <tr>
        <th>{{translate('上课时间')}}</th>
        <th>{{translate('总分')}}</th>
        <th>{{translate('评价')}}</th>
        <th>{{translate('学习课程')}}</th>
        <th>{{translate('演奏')}}</th>
        <th>{{translate('乐理')}}</th>
        <th>{{translate('听力')}}</th>
    </tr>

    {% for d in sessions %}
        <tr>
        <td rowspan={{ d.lessons | length }}>{{ d.time }}</td>
        <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ d.avg_score }}</span></td>
        <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ d.remark }}</span></td>

{#        {% for l, score in d.lessons.iteritems() %}#}
            <td class="name" id="lesson_s.id">{{ translate(d.map + d.evaluation) }}</td>

            <td id="{{ d.lessons[1].evaluation_score.activity_id if 'evaluation_score' in d.lessons[1]}}" >
                <span class="activity
                    {% if 'evaluation_score' not in d.lessons[1] %}notgoing">
                        {{translate('未进行')}}
                    {% else %}">
                        {{ d.lessons[1].evaluation_score._score }}
                        {% if d.lessons[1].evaluation_score.exist_pic %}
                            <i class="iconfont icon-file"></i>
                        {% endif %}
                    {% endif %}
                </span>
            </td>

            <td id="{{ d.lessons[1].evaluation_theory.activity_id if 'evaluation_theory' in d.lessons[1]}}" >
                <span class="activity
                    {% if 'evaluation_theory' not in d.lessons[1] %}notgoing">
                        {{translate('未进行')}}
                    {% else %}">
                        {% if not d.lessons[1].evaluation_theory %}
                            {{translate('无此步骤')}}
                        {% else %}
                            {{ d.lessons[1].evaluation_theory._score }}
                        {% endif %}
                    {% endif %}
                </span>
            </td>

            <td id="{{ d.lessons[1].evaluation_listen.activity_id if 'evaluation_listen' in d.lessons[1]}}" >
                <span class="activity
                    {% if 'evaluation_listen' not in d.lessons[1] %}notgoing">
                        {{translate('未进行')}}
                    {% else %}">
                        {% if not d.lessons[1].evaluation_listen %}
                            {{translate('无此步骤')}}
                        {% else %}
                            {{ d.lessons[1].evaluation_listen._score }}
                        {% endif %}
                    {% endif %}
                </span>
            </td>
            </tr>

            {% if not loop.last%}<tr>{% endif %}
{#        {% endfor %}#}
    {% endfor %}
</table>
{% endif %}

{% if not course_map %}
<table name='mapa' cellpadding="1" border='1'>
    <tr>
        <th>{{translate('上课时间')}}</th>
        <th>{{translate('总分')}}</th>
        <th>{{translate('学习课程')}}</th>
        <th>{{translate('卡拉PK')}}</th>
        <th>{{translate('分句PK')}}</th>
        <th>{{translate('曲谱PK(慢速)')}}</th>
        <th>{{translate('曲谱PK(中速)')}}</th>
        <th>{{translate('曲谱PK(原速)')}}</th>
        <th>{{translate('演奏')}}</th>
    </tr>

    {% for d in sessions %}
    <div>
    </div>
    <tr>
        <td rowspan={{ d.lessons | length }}>{{ d.time }}</td>
        <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ translate(d.remark) }}</span></td>

        {% for l, score in d.lessons.iteritems() %}
        {% if d.is_exp_class == True %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ l }}({{translate('体验班')}})</td>
        {% else %}
            <td class="name" id="lesson_s.id">{{ score.number }}.{{ l }}</td>
        {% endif %}
        <td id="{{ score.pk_kara.activity_id if 'pk_kara' in score}}" >
            <span class="activity{% if 'pk_kara' not in score %}notgoing">{{translate('未进行')}}{% else %}">
                {% if not score.pk_kara %}
                    {{translate('无卡拉PK')}}
                {% else %}
                    {{ score.pk_kara.score }}{% if score.pk_kara.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                {% endif %}
            {% endif %}
            </span>
        </td>
        <td id="{{ score.pk_part.activity_id if 'pk_part' in score}}" >
            <span class="activity{% if 'pk_part' not in score %}notgoing">{{translate('未进行')}}{% else %}">
                {% if not score.pk_part %}
                    {{translate('无分句PK')}}
                {% else %}
                    {{ score.pk_part.score }}{% if score.pk_part.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                {% endif %}
            {% endif %}
            </span>
        </td>
        <td id="{{ score.pk_score_slow.activity_id if 'pk_score_slow' in score}}" >
            <span class="activity{% if 'pk_score_slow' not in score %}notgoing">{{translate('未进行')}}{% else %}">
                {% if not score.pk_score_slow %}
                    {{translate('无曲谱PK')}}
                {% else %}
                    {{ score.pk_score_slow.score }}{% if score.pk_score_slow.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                {% endif %}
            {% endif %}
            </span>
        </td>
        <td id="{{ score.pk_score_mid.activity_id if 'pk_score_mid' in score}}" >
            <span class="activity{% if 'pk_score_mid' not in score %}notgoing">{{translate('未进行')}}{% else %}">
                {% if not score.pk_score_mid %}
                    {{translate('无曲谱PK')}}
                {% else %}
                    {{ score.pk_score_mid.score }}{% if score.pk_score_mid.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                {% endif %}
            {% endif %}
            </span>
        </td>
        <td id="{{ score.pk_score.activity_id if 'pk_score' in score}}" >
            <span class="activity{% if 'pk_score' not in score %}notgoing">{{translate('未进行')}}{% else %}">
                {% if not score.pk_score %}
                    {{translate('无曲谱PK')}}
                {% else %}
                    {{ score.pk_score.score }}{% if score.pk_score.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                {% endif %}
            {% endif %}
            </span>
        </td>
        <td id="{{ score.test_play.activity_id if 'test_play' in score}}" ><span class="activity{% if 'test_play' not in score %}notgoing">{{translate('未进行')}}{% else %}">{{ score.test_play.score }}{% if score.test_play.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span></td>
     </tr>
     {% if not loop.last%}<tr>{% endif %}
         {% endfor %}
    {% endfor %}
</table>
{% endif %}

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"  aria-hidden="true">
  <div class="modal-dialog  modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" id="close1" class="close" sessions-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="modalTitle">{{translate('成绩单')}}</h4>
      </div>
      <div class="modal-body">

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="close2" sessions-dismiss="modal" >{{translate('关闭')}}</button>
      </div>
    </div>
  </div>
</div>

{% endblock %}

{% block js_assets %}
{{ super() }}
<script type="text/javascript">
$('.icon-file').bind('click',function(){
    var activity_id = $(this).parent().parent().attr('id');
    var url = '/school/record/images/' + activity_id;
    $.get(url, function(data){
        if (data['code']!=0){
            alert(data['msg']);
            return;
        }else{
            var htmlStr = '';
            var imagePaths = data['data']['images'];
            for (var i in imagePaths){
                htmlStr += '<img width="800px" src="' + imagePaths[i] + '" />';
            }
            $('#myModal .modal-body').html(htmlStr);
            $('#myModal').modal('show');
            $('.modal-body>img').width('800px');
        }

    }, 'json');
});
$('#close').bind('click',function(){
    $('#myModal').modal('hide');
})
$('#close1').bind('click',function(){
    $('#myModal').modal('hide');
})
$('#close2').bind('click',function(){
    $('#myModal').modal('hide');
})
    function loc(){
        var s = /https?:\/\/.*?\/school\/student_session\/\d+/
        location.href = s.exec(location.href) + $('#sel')[0].value
    }
</script>

{% endblock %}
